package com.lik888.web1.controller;


import com.lik888.web1.entity.AgentTable;
import com.lik888.web1.service.IAgentTableService;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2025-11-14
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/agenttable")
public class AgentTableController {
    private final IAgentTableService agentTableService;

    @GetMapping("/getall")
    @PreAuthorize("hasAuthority('default')")
    public List<AgentTable> getAll(){
        return agentTableService.list();
    }

    @PreAuthorize("hasAuthority('manager')")
    @PostMapping("/add")
    public Boolean add(@RequestBody AgentTable agentTable){
        agentTableService.addService(agentTable);
        return true;
    }

    @DeleteMapping("/delete")
    @PreAuthorize("hasAuthority('manager')")
    public Boolean delete(@RequestParam Integer agentId){
        agentTableService.removeById(agentId);
        return true;
    }

}
